/*    */ package com.zimbra.cs.dav.service.method;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.HttpUtil;
/*    */ import com.zimbra.cs.dav.DavContext;
/*    */ import com.zimbra.cs.dav.DavContext.RequestProp;
/*    */ import com.zimbra.cs.dav.DavElements;
/*    */ import com.zimbra.cs.dav.DavElements.CardDav;
/*    */ import com.zimbra.cs.dav.DavException;
/*    */ import com.zimbra.cs.dav.resource.AddressbookCollection;
/*    */ import com.zimbra.cs.dav.resource.DavResource;
/*    */ import com.zimbra.cs.dav.resource.UrlNamespace;
/*    */ import com.zimbra.cs.dav.service.DavResponse;
/*    */ import java.net.URI;
/*    */ import org.dom4j.Document;
/*    */ import org.dom4j.Element;
/*    */ import org.dom4j.QName;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AddressbookMultiget
/*    */   extends Report
/*    */ {
/*    */   public void handle(DavContext ctxt)
/*    */     throws ServiceException, DavException
/*    */   {
/* 40 */     Element query = ctxt.getRequestMessage().getRootElement();
/* 41 */     if (!query.getQName().equals(DavElements.CardDav.E_ADDRESSBOOK_MULTIGET)) {
/* 42 */       throw new DavException("msg " + query.getName() + " is not addressbook-multiget", 400, null);
/*    */     }
/* 44 */     DavResponse resp = ctxt.getDavResponse();
/* 45 */     DavResource reqResource = ctxt.getRequestedResource();
/* 46 */     if (!(reqResource instanceof AddressbookCollection))
/* 47 */       throw new DavException("requested resource is not an addressbook collection", 400, null);
/* 48 */     DavContext.RequestProp reqProp = ctxt.getRequestProp();
/* 49 */     for (Object obj : query.elements(DavElements.E_HREF)) {
/* 50 */       if ((obj instanceof Element)) {
/* 51 */         String href = ((Element)obj).getText();
/* 52 */         URI uri = URI.create(href);
/* 53 */         String[] fragments = HttpUtil.getPathFragments(uri);
/* 54 */         if (uri.getPath().toLowerCase().endsWith(".vcf"))
/*    */         {
/* 56 */           fragments[(fragments.length - 1)] = HttpUtil.urlEscapeIncludingSlash(fragments[(fragments.length - 1)]);
/*    */         }
/* 58 */         uri = HttpUtil.getUriFromFragments(fragments, uri.getQuery(), true, false);
/* 59 */         href = uri.getPath();
/* 60 */         DavResource rs = UrlNamespace.getResourceAtUrl(ctxt, href);
/* 61 */         if (rs != null) {
/* 62 */           resp.addResource(ctxt, rs, reqProp, false);
/*    */         }
/*    */       }
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/service/method/AddressbookMultiget.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */